package com.jie.eclipse.pan.editors.assist.contributor;


import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;

import com.jie.eclipse.pan.Activator;

/**
 * jspeditor.assistantContributor扩展描述。
 * 中间对象，负责即时加载和创建IAssistantContributor实例
 *
 * @author zhuxing (mailto:zhu_xing@live.cn)
 */
/*
 * 修改历史
 * $Log$ 
 */
public class AssistantContributorDescriptor {
	/**
	 * 扩展对应的configuration element
	 */
	private IConfigurationElement element;
	
	/**
	 * @param element IConfigurationElement
	 */
	public AssistantContributorDescriptor(IConfigurationElement element) {
		this.element = element;
	}

	/**
	 * 获取对应的IAssistantContributor实例
	 * 
	 * @return
	 */
	public IAssistantContributor createContributor() {
		try {
			return (IAssistantContributor)this.element.createExecutableExtension("class");
		} catch (CoreException e) {
			//log exception
			IStatus status = new Status(IStatus.ERROR, "jspeditor", 101, "创建IAssistantContributor实例失败", e);
			Activator.getDefault().getLog().log(status);
			
			return null;
		}
	}
	
}
